/************************************************************************/
// Copyright (C) 2016, han_gangbiao. All rights reserved.
// Use of this source code is governed by a GPL-v2 license that can be found in the License file.
// 
// [Time]:      2016-1-4 21:53:17
// [Author]:    han_gangbiao [http://my.oschina.net/jackhen]
// [Info]:      
/************************************************************************/

#ifndef TPS_CLIENT_H_
#define TPS_CLIENT_H_

#include "net/net_reactor.h"
#include "base/xthread.h"
#include "base/xtime.h"
#include "base/xguard.h"

class CTPSClient : public IEvent_handler
{
public:
	CTPSClient(net_reactor_t* pReactorEngine);
	virtual ~CTPSClient();

public:
	int startConnect(const char* ip, int port);
    int send_data(const char* data, int len);

protected:
	virtual int on_connect( SOCK_FD listen_fd, SOCK_FD cli_fd, const char* remote_ip, int remote_port );
	virtual int on_data( SOCK_FD fd, const char* data, int len, const char* remote_ip, int remote_port );
	virtual int on_send_ack( SOCK_FD fd, int len );
	virtual int on_close( SOCK_FD fd, int error );
    
private:
	net_reactor_t* m_pReactorEngine;
	SOCK_FD m_cli_fd;
};

#endif //~TPS_CLIENT_H_

